package com.allenliu.versionchecklib.utils;

import android.content.Context;
import android.os.Build;
import android.os.Environment;

import java.io.File;

/**
 * @author zhang
 */
public class FileHelper {

    public static String getDownloadApkCachePath(Context context) {
        String appCachePath = null;
        if (checkSDCard()) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                appCachePath = context.getFilesDir() + "/AllenVersionPath/";
            } else {
                appCachePath = Environment.getExternalStorageDirectory() + "/AllenVersionPath/";
            }
        } else {
            appCachePath = Environment.getDataDirectory().getPath() + "/AllenVersionPath/";
        }
        File file = new File(appCachePath);
        if (!file.exists()) {
            file.mkdirs();
        }
        return appCachePath;
    }

    /**
     *
     */
    public static boolean checkSDCard() {
        boolean sdCardExist = Environment.getExternalStorageState().equals(
                Environment.MEDIA_MOUNTED);
        return sdCardExist;
    }

}